#!/usr/bin/env bash
# 一键安装 3x-ui / x-ui（调用官方安装脚本）
set -Eeuo pipefail

type log_info >/dev/null 2>&1 || { echo "[xui_3xui] _common.sh 未加载"; exit 1; }

_install_via_curlbash() {
  local url="$1"
  command -v curl >/dev/null 2>&1 || { log_error "缺少 curl，请先安装网络工具（菜单 12）"; return 1; }
  bash <(curl -Ls "$url")
}

install_3xui() {
  ensure_root
  _install_via_curlbash "https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh"
}

install_xui() {
  ensure_root
  _install_via_curlbash "https://raw.githubusercontent.com/vaxilu/x-ui/master/install.sh"
}
